#include <climits>
#include <iostream>
#include <string>
using namespace std;

int firstUnionChar(string s) {
  int number[26] = {0};
  int loc[26] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  for (int i = 0; i < s.size(); ++i) {
    ++number[s[i] - 'a'];
    if (loc[s[i] - 'a'] == -1) {
      loc[s[i] - 'a'] = i;
    }
  }
  int res = INT_MAX;
  for (int i = 0; i < 26; ++i) {
    if (number[i] == 1 && loc[i] < res) {
      res = loc[i];
    }
  }
  if(res == INT_MAX) return -1; 
  return res;
}

int main() {
  string a = "leetcode";
  cout << firstUnionChar(a) << endl;
}
